//
//  PBFlatBarButtonItems.m
//  FlatUIlikeiOS7
//
//  Created by Piotr Bernad on 11.06.2013.
//  Copyright (c) 2013 Piotr Bernad. All rights reserved.
//

#import "PBFlatBarButtonItems.h"
#import "PBFlatButtonWithIcon.h"
#import "PBBarButtonIconButton.h"
#import "UIImage+JZNExtension.h"
#import "CommonMacro.h"

@implementation PBFlatBarButtonItems

+ (UIBarButtonItem *)barButtonItemWithIconType:(PBFlatIconType)iconType withTarget:(id)target selector:(SEL)selector {

//    PBBarButtonIconButton *button = [[PBBarButtonIconButton alloc] initWithFrame:CGRectMake(0, 0, 64, 44)];
//    [button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
//    [button setType:iconType];
//    
//    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
//    return _barButtonItem;
    
    if (iconType == PBFlatIconAdd) {
        UIButton* btnCloseMenu = [UIButton buttonWithType:UIButtonTypeCustom];
        [btnCloseMenu setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
        //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
        [btnCloseMenu setBackgroundColor:[UIColor clearColor]];
        [btnCloseMenu setImage:[UIImage imageNamed:@"add_friends"] forState:UIControlStateNormal];
        [btnCloseMenu setImage:[UIImage imageNamed:@"add_friends1"] forState:UIControlStateHighlighted];
//        [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
        btnCloseMenu.adjustsImageWhenHighlighted = NO;
        [btnCloseMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnCloseMenu];
        [_barButtonItem setTarget:target];
        return _barButtonItem;
    }
    else{
        UIButton* btnAddMenu = [UIButton buttonWithType:UIButtonTypeCustom];
        [btnAddMenu setFrame:CGRectMake(0, 0, 60, 49)];
        [btnAddMenu setBackgroundColor:[UIColor clearColor]];
        [btnAddMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
        [btnAddMenu setImage:[UIImage imageNamed:@"add_friends_icon"] forState:UIControlStateNormal];
        [btnAddMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnAddMenu];
        [_barButtonItem setTarget:target];
        return _barButtonItem;
    }

}

+ (UIBarButtonItem *)addBarButtonItemWithTarget:(id)target selector:(SEL)selector {
   return [self barButtonItemWithIconType:PBFlatIconAdd withTarget:target selector:selector];
}
+ (UIBarButtonItem *)moreBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    return [self barButtonItemWithIconType:PBFlatIconMore withTarget:target selector:selector];
}
+ (UIBarButtonItem *)menuBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    return [self barButtonItemWithIconType:PBFlatIconMenu withTarget:target selector:selector];
}
+ (UIBarButtonItem *)searchBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    return [self barButtonItemWithIconType:PBFlatIconSearch withTarget:target selector:selector];
}
+ (UIBarButtonItem *)backBarButtonItemWithTarget:(id)target selector:(SEL)selector {
   //return [self barButtonItemWithIconType:PBFlatIconBack withTarget:target selector:selector];
    UIButton* btnCloseMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnCloseMenu setFrame:CGRectMake(0, 0, 20, 20)]; // frame.size.width - 40, 10, 32, 32
    //[btnCloseMenu setBackgroundColor:[UIColor clearColor]];
//    [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateHighlighted];
    btnCloseMenu.adjustsImageWhenHighlighted = NO;// default is YES. if YES, image is drawn darker when highlighted(pressed)
    [btnCloseMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnCloseMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
    
}

+ (UIBarButtonItem *)popToRootBarButtonItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton* btnCloseMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnCloseMenu setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //[btnCloseMenu setBackgroundColor:[UIColor clearColor]];
//    [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    [btnCloseMenu setImage:[UIImage imageNamed:@"navigationBar_back_icon"] forState:UIControlStateNormal];
    [btnCloseMenu setImage:[UIImage imageNamed:@"navigationBar_back_icon1"] forState:UIControlStateHighlighted];
    btnCloseMenu.adjustsImageWhenHighlighted = NO;// default is YES. if YES, image is drawn darker when highlighted(pressed)
    [btnCloseMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnCloseMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem*)cancelBarButtonItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton* cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelButton setFrame:CGRectMake(0, 0, 45, 45)];
    [cancelButton setBackgroundColor:[UIColor clearColor]];
//    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
//    [cancelButton.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
//    [cancelButton setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    [cancelButton setImage:[UIImage imageNamed:@"navigationBar_back_icon"] forState:UIControlStateNormal];
    [cancelButton setImage:[UIImage imageNamed:@"navigationBar_back_icon1"] forState:UIControlStateHighlighted];
    cancelButton.adjustsImageWhenHighlighted = NO;
    [cancelButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cancelButton];
    [barButtonItem setTarget:target];
    
    return barButtonItem;
}

+ (UIBarButtonItem *)forwardBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    return [self barButtonItemWithIconType:PBFlatIconForward withTarget:target selector:selector];
}

+ (UIBarButtonItem *)closeBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    UIButton* btnCloseMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnCloseMenu setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
    [btnCloseMenu setBackgroundColor:[UIColor clearColor]];
    [btnCloseMenu setImage:[UIImage imageNamed:@"navigationBar_close_btn"] forState:UIControlStateNormal];
    [btnCloseMenu setImage:[UIImage imageNamed:@"navigationBar_close_btn1"] forState:UIControlStateHighlighted];
//    [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    btnCloseMenu.adjustsImageWhenHighlighted = NO;
    [btnCloseMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnCloseMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
    
}

+ (UIBarButtonItem *)okBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    UIButton *btnOkMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnOkMenu setFrame:CGRectMake(0, 0, 45, 45)];
    [btnOkMenu setBackgroundColor:[UIColor clearColor]];
    [btnOkMenu setImage:[UIImage imageNamed:@"ok_icon"] forState:UIControlStateNormal];
    [btnOkMenu setImage:[UIImage imageNamed:@"ok_icon1"] forState:UIControlStateHighlighted];
    [btnOkMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnOkMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)nextTimeBarButtonItemWithTarget:(id)target selector:(SEL)selector {
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"下次再说" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 900;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
//    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)registerBarButotnItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"注册" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1000;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)otherDownLoadDataBarButotnItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"其他题库" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(0,0, 55, 45)];
    btnNextTimeMenu.tag = 1001;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
+ (UIBarButtonItem *)editBarButotnItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    btnNextTimeMenu.titleLabel.numberOfLines=0;
    [btnNextTimeMenu setTitle:@"•\n•\n•" forState:UIControlStateNormal];
    btnNextTimeMenu.titleLabel.textAlignment=NSTextAlignmentRight;
    [btnNextTimeMenu.titleLabel  setFont:[UIFont boldSystemFontOfSize:8.f]];
    [btnNextTimeMenu setFrame:CGRectMake(0,0, 20, 30)];
    btnNextTimeMenu.tag = 1002;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
+ (UIBarButtonItem *)inquiryBarButotnItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"我要提问" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1003;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
+ (UIBarButtonItem *)explainBarButotnItemWithTarget:(id)target selector:(SEL)selector{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"我要答疑" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1004;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
+ (UIBarButtonItem *)explainDetailBarButotnItemWithTarget:(id)target selector:(SEL)selector{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"点击答疑" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1005;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)commitBarButotnItemWithTarget:(id)target selector:(SEL)selector{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"发送" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1006;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
+ (UIBarButtonItem *)EditAnswerBarButtonItemWithTarget:(id)target selector:(SEL)selector{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"修改答案" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(3,10, 64.5, 24)];
    btnNextTimeMenu.tag = 1007;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;

}
+ (UIBarButtonItem *)textSizeBarButotnItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:@"" forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel setFont:[UIFont fontWithName:kDefaultFontName size:13.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(0,0, 25, 25)];
    btnNextTimeMenu.tag = 1007;
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"icon_text_size"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)addGroupBarButtonItemWithTarget:(id)target selector:(SEL)selector {

    UIButton* btnAddMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnAddMenu setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
    [btnAddMenu setBackgroundColor:[UIColor clearColor]];
    [btnAddMenu setImage:[UIImage imageNamed:@"add_group_icon"] forState:UIControlStateNormal];
    [btnAddMenu setImage:[UIImage imageNamed:@"add_group_icon_pressed"] forState:UIControlStateHighlighted];
    //        [btnCloseMenu setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    btnAddMenu.adjustsImageWhenHighlighted = NO;
    [btnAddMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnAddMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem*)switchBarButtonItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton* switchButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [switchButton setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
    [switchButton setBackgroundColor:[UIColor clearColor]];
    [switchButton setImage:[UIImage imageNamed:@"showOnMap_icon"] forState:UIControlStateNormal];
    [switchButton setImage:[UIImage imageNamed:@"showOnMap_icon1"] forState:UIControlStateHighlighted];
//    [switchButton setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    switchButton.adjustsImageWhenHighlighted = NO;
    [switchButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:switchButton];
    [_barButtonItem setTarget:target];
    return _barButtonItem;

}

+ (UIBarButtonItem*)listViewBarButtonItemWithTarget:(id)target selector:(SEL)selector;
{
    UIButton* listViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [listViewButton setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
    [listViewButton setBackgroundColor:[UIColor clearColor]];
    [listViewButton setImage:[UIImage imageNamed:@"showOnList_icon"] forState:UIControlStateNormal];
    [listViewButton setImage:[UIImage imageNamed:@"showOnList_icon1"] forState:UIControlStateHighlighted];
//    [listViewButton setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    listViewButton.adjustsImageWhenHighlighted = NO;
    
    [listViewButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:listViewButton];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}


+ (UIBarButtonItem*)doneBarButtonItemWithTarget:(id)target selector:(SEL)selector
{
    UIButton* switchButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [switchButton setFrame:CGRectMake(0, 0, 45, 45)]; // frame.size.width - 40, 10, 32, 32
    //btnCloseMenu.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;
    [switchButton setBackgroundColor:[UIColor clearColor]];
    [switchButton setImage:[UIImage imageNamed:@"selected_icon"] forState:UIControlStateNormal];
    [switchButton setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateHighlighted];
    switchButton.adjustsImageWhenHighlighted = NO;
    [switchButton addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:switchButton];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)syncFavoritesBarButtonItemWithTarget:(id)target selector:(SEL)selector;
{
    UIButton *sync = [UIButton buttonWithType:UIButtonTypeCustom];
    [sync setFrame:CGRectMake(0, 0, 45 , 45)];
//    [sync setBackgroundImage:[UIImage imageNamed:@"navigationBar_button_bg_highlight"] forState:UIControlStateNormal];
    [sync setImage:[UIImage imageNamed:@"sync_icon"] forState:UIControlStateNormal];
    [sync setImage:[UIImage imageNamed:@"sync_icon_hightlighted"] forState:UIControlStateHighlighted];
    [sync.titleLabel setFont:[UIFont systemFontOfSize:12]];
    [sync setAdjustsImageWhenDisabled:NO];
    [sync addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:sync];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}

+ (UIBarButtonItem *)Title:(NSString*) title Target:(id)target selector:(SEL)selector{
    
    UIButton *btnNextTimeMenu = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnNextTimeMenu setTitle:title forState:UIControlStateNormal];
    [btnNextTimeMenu.titleLabel  setFont:[UIFont fontWithName:kDefaultFontName size:15.0f]];
    [btnNextTimeMenu setFrame:CGRectMake(0,0, 55, 45)];
    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"next_time_btn_bg"] stretchImage] forState:UIControlStateNormal];
    //    [btnNextTimeMenu setBackgroundImage:[[UIImage imageNamed:@"btn_next_time_highlighted"] stretchImage] forState:UIControlStateHighlighted];
    [btnNextTimeMenu addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *_barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btnNextTimeMenu];
    [_barButtonItem setTarget:target];
    return _barButtonItem;
}
@end
